import java.util.Arrays;


public class Ex2 {

  /**
   * @param args
   */
  public static void main(String[] args) {
    int[] numbers = {2,3,5,6};
    int key = 12;
    int ix = Arrays.binarySearch(numbers, key);
    if (ix < 0) {
      // calculate insert point from (-(insert point)-1)
      ix = -(ix) - 1;
    }
    // if ix is zero there is no number <= than key
    // if ix is == to array length all numbers are less than key
    // else just get the number under ix
    System.out.println(ix);
  }

}
